package com.funcity.mmo.lengend
{
	import com.funcity.stage.GameStage;
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.events.Event;
	
	import mx.core.FlexGlobals;
	import mx.core.UIComponent;
	
	import spark.components.Application;

	public class Game
	{
		private static var instance:Game;
		
		public var gameStage:GameStage;
		public var width:uint = 0;
		public var height:uint = 0;
		
		
		public static function get ins():Game
		{
			if(instance == null)
			{
				instance = new Game;
			}
			return instance;
		}
		
		public static function get app():Application
		{
			return FlexGlobals.topLevelApplication as Application;
		}
		
		public static function get stageWidth():uint
		{
			return app.stage.stageWidth;
		}
		
		public static function get stageHeight():uint
		{
			return app.stage.stageHeight;
		}
		
		public function Game():void
		{
			app.addEventListener(Event.ADDED_TO_STAGE, 
			function init(e:Event):void
			{
				initStage();
				initUI();
			});
		}
		
		private function initStage():void
		{
			gameStage = new GameStage(new Vector.<BitmapData>);
			var uc:UIComponent = new UIComponent();
			uc.addChild(gameStage);
			app.addElement(uc);
			Game.ins.gameStage.changeMap("MAP_01_001");
		}
		
		private function initUI():void
		{
			
		}
	}
}